home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / disasm.zip / UASM-JMP.BAS < prev    next >
BASIC Source File  |  1988-06-03  |  9KB  |  160 lines

  1. 10 '--------------------------------------------------------------------------
  2. 11 '|    UASM-JMP  1.05        12 Sept, 1983        White Crane Systems  |
  3. 12 '|    copyright 1983        Guy C. Gordon        3194 Friar Tuck Way  |
  4. 13 '|                            Doraville, GA 30340  |
  5. 14 '|                                         |
  6. 16 '|    This program takes the Unassemble output from DEBUG and changes         |
  7. 18 '|    all Jump, Call and Loop addresses into labels of the form Lhhhh         |
  8. 20 '|    where hhhh is the hex address.  All addresses are stripped from         |
  9. 22 '|    the lines except those referenced in this block of code, which         |
  10. 24 '|    are made into labels.   Your unassembled input file should con-         |
  11. 26 '|    sist of all of the code and none of the data areas.             |
  12. 28 '|                                         |
  13. 30 '|    In addition, blank lines are inserted after all unconditional          |
  14. 32 '|    program transfers (JMP, JMPS, RET, IRET) to make the division of     |
  15. 34 '|    the program into subroutines more visible.  Such lines are forced    |
  16. 35 '|    to have labels, even if not referenced anywhere in the code.         |
  17. 36 '|    A warning comment is appended in this case.                 |
  18. 40 '|                                         |
  19. 42 '|    UASM-JMP replaces COM2ASM by Richard Winkel on which it is based.    |
  20. 44 '|    It gives about a 2X advantage in speed,  depending on file size.     |
  21. 46 '|    For best speed, and to save wear on your drives, specify the in-     |
  22. 48 '|    put and output files on separate drives.                   |
  23. 50 '********************************* NOTICE *********************************
  24. 51 '*          USER SUPPORTED SOFTWARE (With thanks to Andrew Flugelman)     *
  25. 52 '*                                                                        *
  26. 53 '*   A limited license is granted to all users of this program, to make   *
  27. 54 '*   copies of this program and distribute them to other users subject    *
  28. 55 '*   to the following conditions:                                         *
  29. 56 '*           1.  None of the notices or credits are to be bypassed,       *
  30. 57 '*               altered, or removed.                                     *
  31. 58 '*           2.  The program is not to be distributed in modified form.   *
  32. 59 '*               (Users are encouraged to distribute MERGE files.)        *
  33. 60 '*           3.  No fee is to be charged (or any other consideration      *
  34. 61 '*               received) for copying or distributing the program        *
  35. 62 '*               without an express written agreement with                *
  36. 63 '*               White Crane Systems.                                     *
  37. 64 '**************************************************************************
  38. 70 CLS 'PRINT CHR$(27)+"E";   'CLS
  39. 71 PRINT "                                UASM-JMP
  40. 72 PRINT "              White Crane Systems Unassembler - Jump module
  41. 73 PRINT "
  42. 74 PRINT "           If you are using this program and finding it of value
  43. 75 PRINT "      please send  a cash contribution to support its upkeep and
  44. 76 PRINT "      distribution.   Use the UASM system  of programs to  unas-
  45. 77 PRINT "      semble one average length .COM file, look over the results
  46. 78 PRINT "      and calculate how many hours this would have taken you  to
  47. 79 PRINT "      to produce,  multiply by the minimum wage, contribute that
  48. 80 PRINT "      amount and use the program free thereafter.  If that's too
  49. 81 PRINT "      much just send $20.   Supporters will receive  free notice 
  50. 82 PRINT "      of enhancements and updates.
  51. 83 PRINT "           In any case you are encouraged to copy and distribute 
  52. 84 PRINT "      UASM to your friends provided you do so free of charge and
  53. 85 PRINT "      in unmodified form.
  54. 87 PRINT " 
  55. 88 PRINT "                          Guy C. Gordon
  56. 89 PRINT "                          White Crane Systems
  57. 90 PRINT "            3194 Friar Tuck Way
  58. 91 PRINT "                          Doraville, GA 30340
  59. 100                'INITIALIZATION
  60. 110 DEFINT A-Z
  61. 120 DIM LIN$(999)
  62. 130 TRUE=(1=1): FALSE=NOT TRUE: BELL$=CHR$(7)
  63. 132 WARNING$=":        ; WARNING!  No code for this label"
  64. 135 PRINT
  65. 140 INPUT "Enter name of  input file: ",INFILE$
  66. 150    DR=INSTR(INFILE$,":"): EXT=INSTR(INFILE$,".")
  67. 160    IF EXT=0 THEN INFILE$=INFILE$+".DB": EXT=INSTR(INFILE$,".")
  68. 170 INPUT "Enter name of output file: ",OUTFILE$
  69. 173    IF INSTR(OUTFILE$,":")=LEN(OUTFILE$) THEN OUTFILE$=OUTFILE$+MID$(INFILE$,DR+1,EXT-DR-1)
  70. 175    IF INSTR(OUTFILE$,".")=0 THEN OUTFILE$=OUTFILE$+".JMP"
  71. 180 OPEN INFILE$ FOR INPUT AS #1
  72. 190 OPEN OUTFILE$ FOR OUTPUT AS #2: PRINT #2,".RADIX    16": PRINT #2,
  73. 200 '
  74. 400 '-------------------------------------------------------------------------
  75. 401 '                READ INPUT FILE        (First pass)         |
  76. 402 '-------------------------------------------------------------------------
  77. 405 PRINT: PRINT "Pass 1:   Reading "INFILE$: T1$=TIME$
  78. 410 WHILE NOT EOF(1)
  79. 420   LINE INPUT #1,A$: IF LEN(A$)<28 THEN 480
  80. 425   '                look for various Jumps, CALL, or LOOP
  81. 430   IF MID$(A$,25,1)<>"J" AND MID$(A$,25,4)<>"CALL" AND MID$(A$,25,4)<>"LOOP" THEN 480
  82. 440   '                make certain we have found a hex address
  83. 450   IF MID$(A$,33,1)<"0" OR MID$(A$,33,1)>"F" OR MID$(A$,34,1)<"0" OR MID$(A$,34,1)>"F" OR MID$(A$,35,1)<"0" OR MID$(A$,35,1)>"F" OR MID$(A$,36,1)<"0" OR MID$(A$,36,1)>"F" THEN 480
  84. 455   '                skip termination or inter-segment jumps
  85. 460   IF MID$(A$,33,4)="0000" OR MID$(A$,37,1)=":" THEN 480
  86. 470   LIN=LIN+1: LIN$(LIN)=MID$(A$,33,4)    'Found a reference
  87. 480 WEND
  88. 490 CLOSE #1            'done with first pass
  89. 500 '
  90. 600 '-------------------------------------------------------------------------
  91. 601 '                SUPER SHELL SORT (Byte, May '83)         |
  92. 602 '-------------------------------------------------------------------------
  93. 605 T2$=TIME$
  94. 610 PRINT "Sorting:  ";        'sort referenced addresses
  95. 620 D=2^INT(LOG(LIN)/LOG(2))-1 
  96. 630 FOR I=1 TO LIN-D
  97. 640   IF LIN$(I)<=LIN$(I+D) THEN 700 ELSE T$=LIN$(I+D):LIN$(I+D)=LIN$(I)
  98. 650   IF I<=D THEN LIN$(I)=T$:GOTO 700
  99. 670   FOR J=I-D TO 1 STEP -D:IF T$>=LIN$(J) THEN 690 ELSE LIN$(J+D)=LIN$(J):NEXT
  100. 690   LIN$(J+D)=T$
  101. 700 NEXT I: PRINT ".";
  102. 710 D=INT(D/2):IF D>0 THEN 630 ELSE PRINT: PRINT
  103. 800 '-------------------------------------------------------------------------
  104. 801 '                ELIMINATE DUPLICATE REFERENCES             |
  105. 802 '-------------------------------------------------------------------------
  106. 805 T3$=TIME$
  107. 810 I=1: FOR J=2 TO LIN
  108. 820   IF LIN$(I)=LIN$(J) THEN 840
  109. 830   I=I+1: IF J<>I THEN LIN$(I)=LIN$(J)
  110. 840 NEXT J
  111. 850 LIN=I
  112. 1000 '------------------------------------------------------------------------
  113. 1001 '                READ INPUT & WRITE OUTPUT  (Pass 2)         |
  114. 1002 '------------------------------------------------------------------------
  115. 1010 T4$=TIME$: L=1     'now go back thru file and plug in labels for addresses
  116. 1020 OPEN INFILE$ FOR INPUT AS #1
  117. 1030 FORCE.LABEL=TRUE        'First line is force labeled
  118. 1040 WHILE NOT EOF(1) 
  119. 1050   LINE INPUT #1, A$: IF LEN(A$)<28 THEN 1490
  120. 1100   '            Label This Line?
  121. 1110   T$=MID$(A$,6,4)            'offset of this line
  122. 1120   IF T$=LIN$(L) THEN MID$(A$,6,6)="L"+T$+":":  L=L+1:  FORCE.LABEL=FALSE:  GOTO 1200
  123. 1125   IF FORCE.LABEL AND T$="0100" THEN MID$(A$,6,6)="START:":FORCE.LABEL=FALSE: GOTO 1200
  124. 1130   IF FORCE.LABEL THEN MID$(A$,6,6)="L"+T$+":" ELSE MID$(A$,6,6)=SPACE$(6)
  125. 1150   IF T$<=LIN$(L) OR L>LIN THEN 1200
  126. 1160   PRINT BELL$:   PRINT "L"+LIN$(L)+WARNING$: PRINT
  127. 1170   PRINT #2,: PRINT #2, "L"+LIN$(L)+WARNING$: PRINT #2,
  128. 1190   L=L+1: GOTO 1120        'Loop back and test next reference
  129. 1200   '                Find reference in this line
  130. 1210   IF MID$(A$,25,1)<>"J" AND MID$(A$,25,4)<>"CALL" AND MID$(A$,25,4)<>"LOOP" THEN 1300
  131. 1220   IF MID$(A$,33,1)<"0" OR MID$(A$,33,1)>"F" OR MID$(A$,34,1)<"0" OR MID$(A$,34,1)>"F" OR MID$(A$,35,1)<"0" OR MID$(A$,35,1)>"F" OR MID$(A$,36,1)<"0" OR MID$(A$,36,1)>"F" OR MID$(A$,37,1)=":" THEN 1300
  132. 1230   A$=LEFT$(A$,32)+"L"+MID$(A$,33)        'Make destination addr. a label
  133. 1300   '                Test for "The Force"
  134. 1310   IF NOT FORCE.LABEL THEN 1400
  135. 1320   I=LEN(A$): WHILE MID$(A$,I,1)=" " AND I>26: I=I-1: WEND 'last non-blank
  136. 1330   A$=LEFT$(A$,I)+"        ;WARNING!  This label not referenced"
  137. 1340   PRINT BELL$;
  138. 1350   FORCE.LABEL=FALSE
  139. 1400   '                FINALLY, print the thing
  140. 1410   I=LEN(A$): WHILE MID$(A$,I,1)=" " AND I>26: I=I-1: